/**
 * Created by john on 2017/08/18.
 */
const request = require('request');

exports.requestLocation = function (params) {
    console.log("location=====>", params);
    return new Promise(function (resolve, reject) {
        let options = {
            uri: 'http://apis.map.qq.com/ws/geocoder/v1/?location=' + params.lat + ',' + params.lng + '&key=WVGBZ-JKHRX-UIB4V-TYXZU-GY3L5-N2BZZ',
            headers: {"Content-Type": "application/json",},
            method: 'get',
            body: JSON.stringify(params)
        };
        console.log("locationoptions=====>", options);
        request(options, function (err, response, body) {
            if (err) {
                reject(err);
            } else {
                let _body = JSON.parse(body).result.ad_info;
                resolve(_body);
            }
        })
    });
};
